#include <bits/stdc++.h>
using namespace std;
int t;
long long n,sum=0,a[100005],ans = 0,book[100005];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout)
    cin >> t;
    while(t--)
    {
        cin >> n;int y = 0;int x = 0;ans = 0;sum = 0;
        for (int i = 1;i <= 100000;i++)
        {
            a[i] = 0;
        }
        for (int i = 1;i <= n;i++)
        {
            cin >> y;
            book[i] = y;

            a[y]++;
        }
        sort(book+1,book+n+1);
        for (int i =1;i <= n;i++)
        {
            if (x != book[i])
            {
                x = book[i];
                sum++;
            }
        }
        cout << sum;
        if (sum == 1)
        {

            cout << x*a[x]-x << endl;
            continue;
        }
        if (sum == 2)
        {
            for (int i = 1;i <= 100000;i++)
            {
                if (a[i]!= 0)
                    ans += a[i]*i-i;
            }
            cout << ans << endl;
            continue;
        }
        else{
            for (int i = 1;i <= 100000;i++)
            {
                ans = max(ans,a[i]*i-i);
            }
            cout << ans << endl;
            continue;
        }


    }
    return 0;
}
